<include file="public@header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a >等待审核列表</a></li>
			<!-- <li><a href="{:url('Dynamic/add')}">添加</a></li> -->
		</ul>
        
        <form class="well form-inline margin-top-20" method="post" action="{:url('Dynamic/index')}">
			排序：
			<select class="form-control" name="ordertype" style="width: 150px;">
				<option value="">默认</option>
				<option value="1" <if condition="input('request.ordertype') eq '1'">selected</if> >评论数排序</option>
				<option value="2" <if condition="input('request.ordertype') eq '2'">selected</if> >点赞数排序</option>
			</select>
			动态类型：
            <select class="form-control" name="dttype" style="width: 150px;">
                <option value=''>全部</option>
                <volist name="dttype" id="v">
                    <option value="{$key}" <if condition="input('request.dttype') neq '' && input('request.dttype') eq $key">selected</if>>{$v}</option>
                </volist>
            </select>
            关键字：
            <input class="form-control" type="text" name="uid" style="width: 200px;" value="{:input('request.uid')}" placeholder="请输入用户ID">
            <input class="form-control" type="text" name="dynamicid" style="width: 200px;" value="{:input('request.dynamicid')}" placeholder="请输入动态ID">
			<input class="form-control" type="text" name="keyword1" style="width: 200px;" value="{:input('request.keyword1')}" placeholder="请输入动态标题">
	
            <input type="submit" class="btn btn-primary" value="搜索"/>
            <a class="btn btn-danger" href="{:url('Dynamic/index')}">清空</a>
        </form>
        
		<form method="post" class="js-ajax-form" >
            <div class="table-actions">
                <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="{:url('dynamic/del')}"
                        data-subcheck="true">批量删除
                </button>
            </div>
			<table class="table table-hover table-bordered">
				<thead>
					<tr>
                        <th width="16">
                            <label>
                                <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                            </label>
                        </th>
						<th>ID</th>
						<th>用户(ID)</th>
						<th>标题</th>
						<th >封面</th>
					<!-- 	<th  style="max-width:100px;">视频地址</th>
						<th  style="max-width:100px;">语音地址</th> -->
						<th>点赞数量</th>
						<th>评论数量</th>
						<th>动态类型</th>
                        <th>发布时间</th>
                        <th>状态</th>
						<th align="center">{:lang('ACTIONS')}</th>
					</tr>
				</thead>
				<tbody>
				<php>
					$type=array("0"=>"纯文字","1"=>"文字+图片","2"=>"文字+视频","3"=>"文字+语音");
				</php>
					<foreach name="list" item="vo">
					<tr>
                        <td>
                            <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}">
                        </td>
						<td>{$vo['id']}</td>
                        <td>{$vo['userinfo']['user_nickname']} ({$vo['uid']})</td>
						<td>{$vo['title']}</td>
                        <td>
						<if condition="$vo.type eq '1'">
							<img src="{$vo['thumbs']}" class="imgtip" style="max-width:100px;max-height:100px;">
						<elseif condition="$vo.type eq '2'"/>
							<img src="{$vo['video_thumb']}" class="imgtip" style="max-width:100px;max-height:100px;">
						<else/>
						</if>
						</td>
                    <!--     <td  style="max-width:100px;">{$vo['href']}</td>
                        <td  style="max-width:100px;">{$vo['voice']}</td> -->
                        <td>{$vo['likes']}</td>
                        <td>{$vo['comments']}</td>
                        <td>{$type[$vo['type']]}</td>
                        <td>{:date('Y-m-d H:i',$vo['addtime'])}</td>
                        <td>{$status[$vo['status']]}</td>
						<td>
							<if condition="$vo['type'] eq 2">
								<a class="btn btn-xs btn-info view" data-id="{$vo['id']}" >观看视频</a>
							<elseif  condition="$vo['type'] eq 1 "/>
								<a class="btn btn-xs btn-info" href='{:url("Dynamic/look",array("id"=>$vo["id"]))}'>查看图片</a>
							<elseif  condition="$vo['type'] eq 3 "/>
								<a class="btn btn-xs btn-info playyy" data-id="{$vo['id']}" >播放语音</a>
							<else/>
							</if>
                            <if condition="$vo['status'] eq 0">
                                <a class="btn btn-xs btn-success setstatus" data-id="{$vo['id']}" data-status="1">同意</a>
                                <a class="btn btn-xs btn-danger setstatus" data-id="{$vo['id']}" data-status="2">拒绝</a>
                            </if>
                            
                            <if condition="$vo['status'] eq 1">
                                <a class="btn btn-xs btn-danger setstatus" data-id="{$vo['id']}" data-status="2">拒绝</a>
                            </if>
                            
                            <if condition="$vo['status'] eq 2">
                                <a class="btn btn-xs btn-success setstatus" data-id="{$vo['id']}" data-status="1">同意</a>
                            </if>
							<!-- <a class="btn btn-xs btn-success" href='{:url("Dynamic/commentlists",array("id"=>$vo["id"]))}'>评论列表</a> -->
							<a class="btn btn-xs btn-success" href="javascript:parent.openIframeLayer('{:url('Dynamic/commentlists',array('id'=>$vo['id']))}','评论列表',{});">评论列表</a>
                            <!-- <a class="btn btn-xs btn-primary" href='{:url("Dynamic/edit",array("id"=>$vo["id"]))}'>{:lang('EDIT')}</a> -->
							<a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('Dynamic/del',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
						</td>
					</tr>
					</foreach>
				</tbody>
			</table>
			<div class="pagination">{$page}</div>

		</form>
	</div>
    <div id="enlarge_images" style="position:fixed;display:none;z-index:2;background:#fff;"></div>
	<script src="__STATIC__/js/admin.js"></script>
        <script>
        $(function(){
            var ei=$('#enlarge_images');
            var imgtip=$('.imgtip');
            
            imgtip.mousemove(function(event){
                event = event || window.event;
                
                var html = '<img src="' + this.src + '" style="max-width:500px;max-height:500px;"/>';
                
                ei.html(html);
                var top  = document.body.scrollTop + event.clientY + 10 + "px";
                var left = document.body.scrollLeft + event.clientX + 10 + "px";
            
                var css={
                    'display':'block',
                    'top':top,
                    'left':left,
                }
                ei.css(css);
            })
            
            imgtip.mouseout(function(){
                ei.html('');                
                var css={
                    'display':'none',
                }
                ei.css(css);
            })
            imgtip.click(function(){
                ei.html('');                
                var css={
                    'display':'none',
                }
                ei.css(css);
                window.open( this.src );
            })
            Wind.use('layer');
            $('.setstatus').click(function(){
                var _this=$(this);
                var id=_this.data('id');
                var status=_this.data('status');
                var value=' ';

                layer.prompt({
                    formType: 2,
                    title: '审核意见',
                    value: value,
                    area: ['800px', '100px'] //自定义文本域宽高
                }, function(value, index, elem){
					if(status==2){
						value=value.trim();
						if(value=='' || !value){
							layer.msg("请填写审核意见");
							return !1;
						}
					}
                    $.ajax({
                        url:'{:url('Dynamic/setstatus')}',
                        type:'POST',
                        data:{id:id,status:status,reason:value},
                        dataType:'json',
                        success:function(data){
                            var code=data.code;
                            if(code==0){
                                layer.msg(data.msg);
                                return !1;
                            }
                            layer.msg(data.msg,{},function(){
                                layer.closeAll();
                                reloadPage(window);
                            });
                            
                        },
                        error:function(){
                            layer.msg('操作失败，请重试');
                        }
                    });
                    
                });
                
            })

            $('.view').click(function(){
                var _this=$(this);
                var id=_this.data('id');

                layer.open({
                    type: 2,
                    title: '观看视频',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['500px', '750px'],
                    content: '/admin/Dynamic/view?id='+id
                }); 
                
            });
			//播放语音
            $('.playyy').click(function(){
                var _this=$(this);
                var id=_this.data('id');
                layer.open({
                    type: 2,
                    title: '播放语音',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['400px', '250px'],
                    content: '/admin/Dynamic/playyy?id='+id
                }); 
                
            })
        })
    </script>    
</body>
</html>